﻿import kliment.utils._Object;
import kliment.utils._Type;
/**
 * ...
 * @author	Kliment
 * @version	1.0.0
 */
dynamic class kliment.net.URLVariables {
	
	public function URLVariables(source) {
		decode(source);
	}
	
	public function decode(source):Void {
		if (_Type.isString(source)) {
			var loadVars:LoadVars = new LoadVars();
			loadVars.decode(source);
			_Object.copyTo(loadVars, this);
		}else if (_Type.isObject(source)) {
			_Object.copyTo(source, this);
		}
	}
	
	public function toString():String {
		var list:Array = new Array();
		for (var i in this) 
			list.push(i + '=' + this[i]);
		return list.join('&');
	}
	
	public function toStringGET():String {
		var result:String = toString();
		if (result.length) 
			return '?' + result;
		return '';
	}
}